package com.niodata.dp.app;

import com.niodata.dp.task.entity.ParamType;
import java.util.List;
import java.util.Map;

public interface VariableManager {

  /**
   * create new variable.
   *
   * @param appId app id
   * @param name name
   * @param description desc
   */
  public void createVariable(String appId, String appCode,
      VariableType type, ParamType paramType,
      String name, String description,
      String taskName, String job, String param, Object initValue);

  public void update(AppVariable appVariable);


  public void deleteVariable(String appId, String name);

  /**
   * bind variable to flow out put param.
   *
   * @param appId appid
   * @param varName var name
   * @param taskId task id
   * @param jobName job name
   * @param jobParam job param
   */
  public void bindVariable(String appId, String varName,
      String taskId, String jobName, String jobParam);

  /**
   * unbind variable from flow.
   *
   * @param appId appid
   * @param varName var name
   */
  public void unBindVariable(String appId, String varName);

  /**
   * check if variable bind to any flow.
   *
   * @param appId app id
   * @param varName var name
   * @return bind
   */
  public boolean isBind(String appId, String varName);

  /**
   * get variable.
   *
   * @param appId appid
   * @param name name
   * @return variable
   */
  public AppVariable getVariable(String appId, String name);

  /**
   * get variable by appcode.
   *
   * @param appCode appcode
   * @param name var name
   * @return variable
   */
  public AppVariable getVariableByAppCode(String appCode, String name);

  /**
   * get app variables.
   *
   * @param appid appid
   * @param offset offset
   * @param count max count
   * @return variable list
   */
  public List<AppVariable> getVariables(long userId, String appid, String keyWord, int offset,
      int count);

  /**
   * apply flow output values to variables.
   *
   * @param taskName task name
   * @param jobName job name
   * @param values output values
   */
  public void applyUpdate(String taskName, String jobName, Map<String, Object> values);

}
